package gameModel;


public class StdCard implements Card {

	// ATTRIBUTS
	
	private final CardTypes type;
	private final GameModel game;
	private boolean used;
	private int useDelay;
	
	// CONSTRUCTEUR
	
	public StdCard(CardTypes t, GameModel game) {
		type = t;
		useDelay = t.getUseDelay();
		this.game = game;
		used = false;
	}
	
	// REQUETES
	
	@Override
	public CardTypes getType() {
		return type;
	}
	
	@Override
	public GameModel getGameModel() {
		return game;
	}
	
	@Override
	public String getTitle() {
		return type.getTitle();
	}

	@Override
	public boolean isGuard() {
		return false;
	}

	@Override
	public int getUseDelay() {
		return useDelay;
	}

	@Override
	public boolean isUsable() {
		return !used && useDelay == 0;
	}

	// COMMANDES
	
	@Override
	public void active(Object o) {
		if (!isUsable()) {
			throw new IllegalStateException();
		}
		type.active(game, o);
		used = true;
	}

	@Override
	public void reactive() {
		used = false;
	}
	
	@Override
	public void oneTurn() {
		if (useDelay > 0) {
			useDelay--;
		}
	}

}
